﻿using System;

namespace Infrastucture
{
    public class DateRange
    {
        private DateTime _startDate;
        private DateTime _endDate;

        public DateRange()
        {
            // emprty constructor
        }
        public DateRange(DateTime startDate, DateTime endDate)
        {
            this.StartDate = startDate;
            this.EndDate = endDate;
        }


        public DateTime StartDate 
        {
            get { return _startDate; }
            set
            {
                if (this.StartDate == value) return;
                _startDate = value;
                this.TimeSpan = this.EndDate.Subtract(this.StartDate);
            }
        }
        public DateTime EndDate
        {
            get { return _endDate; }
            set
            {
                if (this.EndDate == value) return;
                _endDate = value;
                this.TimeSpan = this.EndDate.Subtract(this.StartDate);
            }
        }
        public TimeSpan TimeSpan { get; private set; }
    }

    public struct daterange
    {
        private DateTime _startDate;
        private DateTime _endDate;
        private TimeSpan _timeSpan;

        public daterange(DateTime startDate, DateTime endDate)
        {
            _startDate = startDate;
            _endDate = endDate;
            _timeSpan = _endDate.Subtract(_startDate);
        }


        public DateTime StartDate
        {
            get { return _startDate; }
            set
            {
                _startDate = value;
                this.TimeSpan = this.EndDate.Subtract(this.StartDate);
            }
        }
        public DateTime EndDate
        {
            get { return _endDate; }
            set
            {
                _endDate = value;
                this.TimeSpan = this.EndDate.Subtract(this.StartDate);
            }
        }
        public TimeSpan TimeSpan 
        {
            get { return _timeSpan; }
            private set { _timeSpan = value; }
        }
    }
}
